package com.burstly.lib.component;

import android.content.Context;
import com.burstly.lib.component.networkcomponent.NetworkAwareControllerWrapper;
import com.burstly.lib.feature.networks.IAdaptorFactory;
import com.burstly.lib.network.beans.RequestData;
import com.burstly.lib.network.beans.ResponseBean;
import com.burstly.lib.network.beans.ResponseBean.ResponseData;
import com.burstly.lib.persistance.ResponseSaver;
import com.burstly.lib.util.LoggerExt;
import java.util.HashMap;
import java.util.Map;

public class ComponentQueueElement
{
  private static final String ADAPTOR_NAME_KEY = "adaptorName";
  private static final String CONTEXT_KEY = "context";
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final String TAG = "ComponentQueueElement";
  private static final String VIEW_ID_KEY = "viewId";
  private final String mAdaptorName;
  private final String mBurstlyViewId;
  private ResponseBean.ResponseData mCreativeData;
  private final String mFactoryClassName;
  private String mFactoryId;
  private RequestData mFullRequest;
  private ResponseBean mFullResponse;

  ComponentQueueElement(String paramString1, String paramString2, String paramString3)
  {
    this.mBurstlyViewId = paramString1;
    this.mAdaptorName = paramString2;
    this.mFactoryClassName = paramString3;
    this.mFactoryId = paramString2;
  }

  protected AdaptorController createAdaptorController(ControllerConfig paramControllerConfig)
  {
    return new AdaptorController(paramControllerConfig);
  }

  protected ControllerConfig createControllerConfig(Context paramContext, IBurstlyAdaptor paramIBurstlyAdaptor)
  {
    ControllerConfig localControllerConfig = new ControllerConfig();
    localControllerConfig.setAdaptor(paramIBurstlyAdaptor);
    localControllerConfig.setContext(paramContext);
    localControllerConfig.setCreativeData(this.mCreativeData);
    localControllerConfig.setResponseBean(this.mFullResponse);
    localControllerConfig.setRequestData(this.mFullRequest);
    localControllerConfig.setBurstlyViewId(this.mBurstlyViewId);
    return localControllerConfig;
  }

  protected Map<String, Object> createFactoryParameters(Object paramObject)
  {
    HashMap localHashMap = new HashMap(4);
    localHashMap.put("context", paramObject);
    localHashMap.put("viewId", this.mBurstlyViewId);
    localHashMap.put("adaptorName", this.mAdaptorName);
    return localHashMap;
  }

  IAdaptorController getController(Map<String, ?> paramMap)
  {
    if ((paramMap != null) && (paramMap.get("context") != null))
    {
      Object localObject1 = paramMap.get("context");
      IBurstlyAdaptor localIBurstlyAdaptor = tryToCreateAdaptor(paramMap, localObject1);
      if (localIBurstlyAdaptor != null)
      {
        AdaptorController localAdaptorController = createAdaptorController(createControllerConfig((Context)localObject1, localIBurstlyAdaptor));
        Object localObject2 = paramMap.get("responseSaver");
        if ((localObject2 != null) && ((localObject2 instanceof ResponseSaver)))
          localAdaptorController.setResponseSaver((ResponseSaver)localObject2);
        return new NetworkAwareControllerWrapper(localAdaptorController);
      }
    }
    return null;
  }

  ResponseBean.ResponseData getCreativeData()
  {
    return this.mCreativeData;
  }

  String getFactoryId()
  {
    return this.mFactoryId;
  }

  RequestData getFullRequest()
  {
    return this.mFullRequest;
  }

  void setCreativeData(ResponseBean.ResponseData paramResponseData)
  {
    this.mCreativeData = paramResponseData;
  }

  void setFactoryId(String paramString)
  {
    this.mFactoryId = paramString;
  }

  void setFullRequest(RequestData paramRequestData)
  {
    this.mFullRequest = paramRequestData;
  }

  void setFullResponse(ResponseBean paramResponseBean)
  {
    this.mFullResponse = paramResponseBean;
  }

  public String toString()
  {
    return "QueueElement for " + this.mAdaptorName;
  }

  IBurstlyAdaptor tryToCreateAdaptor(Map<String, ?> paramMap, Object paramObject)
  {
    IAdaptorFactory localIAdaptorFactory = AdaptorFactoryCache.getFactory(this.mFactoryClassName, this.mFactoryId, paramMap);
    IBurstlyAdaptor localIBurstlyAdaptor;
    if (localIAdaptorFactory != null)
    {
      Map localMap = createFactoryParameters(paramObject);
      LOG.logDebug("ComponentQueueElement", "Creating adaptor...", new Object[0]);
      localIBurstlyAdaptor = localIAdaptorFactory.createAdaptor(localMap);
      if (localIBurstlyAdaptor != null);
    }
    else
    {
      return null;
    }
    return new AdaptorWrapper(localIBurstlyAdaptor, localIAdaptorFactory);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.ComponentQueueElement
 * JD-Core Version:    0.6.2
 */